﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "教学运行管理 - 考试安排 - 补考安排时间与地点");

		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		
		termId = event.getArg("TermID");
		depId = sessionAdvice.getUserProp("teacherDepartment");

		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		currentTab = event.getArg("TabID", "labNone");
		
		passArgs = structNew();
		
		targetArgs = structNew();
		structInsert(targetArgs, "TID", termId);
		
		sql = "SELECT 
					t_resittask.task_exrstid,
					t_course.course_name, 
					t_campus.campus_name,
					t_resittask.wid, 
					t_resittask.examer_sum, 
					t_institute.institute_short  
				FROM 
					t_resittask  
					INNER JOIN t_course ON t_course.cid = t_resittask.cid 
					INNER JOIN t_campus ON t_campus.campus_id = t_resittask.campus_id 
					INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
				WHERE 
					t_resittask.term_id = :termId 
					AND 
					t_course.institute_id = :depId 
					AND 
					(t_resittask.task_prog = '0' OR t_resittask.task_prog = '1' OR t_resittask.task_prog = '2' )
				ORDER BY 
					t_resittask.wid "; 
		
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_task = queryObj.execute( sql=sql ).getResult();
		
		
		sql = "SELECT 
					t_resittask.task_exrstid,
					t_course.course_name, 
					t_campus.campus_name,
					t_resittask.wid, 
					t_resittask.examer_sum, 
					t_institute.institute_short, 
					t_resittask.wdidx,
					t_resittask.cellidx, 
					(SELECT COUNT(DISTINCT cr_id) FROM t_student_resit WHERE t_student_resit.task_exrstid = t_resittask.task_exrstid) countCrId      
				FROM 
					t_resittask  
					INNER JOIN t_course ON t_course.cid = t_resittask.cid 
					INNER JOIN t_campus ON t_campus.campus_id = t_resittask.campus_id 
					INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
				WHERE 
					t_resittask.term_id = :termId 
					AND 
					t_course.institute_id = :depId 
					AND 
					t_resittask.task_prog = '3' 
				ORDER BY 
					t_resittask.wid "; 
		
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_taskPublish = queryObj.execute( sql=sql ).getResult();
	
		
		if ( currentTab eq "labNone" and rs_task.recordCount eq 0 and rs_taskPublish.recordCount gt 0 ) {
			currentTab = event.getArg("TabID", "labPublished");
		}
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">考试安排</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 exam"></i>补考时间、地点安排
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix">
			
				<div class="UItab">
					<div class="tabLables">
						<cfif rs_task.recordCount>
							<span <cfif currentTab eq "labNone">class="active"</cfif> id="labNone" tabTarget="None">编排中</span>
						</cfif>
						<cfif rs_taskPublish.recordCount>
							<span <cfif currentTab eq "labPublished">class="active"</cfif> id="labPublished" tabTarget="Published">已发布</span>
						</cfif>
					</div>
				</div>
				
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<cfif rs_task.recordCount>
					<div id="None" class="tabContent">
					
						<div class="noticeBlock">
							<h3>尚未发布补考任务</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 尚有<em><cfoutput>#rs_task.recordCount#</cfoutput></em>场次考试需要安排时间和考试场地.</p>
						</div>
					
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="25"></td>
									<td width="50">任课单位</td>
									<td>课程</td>
									<td width="50">考试校区</td>
									<td width="30">周次</td>
									<td width="40">人数</td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_task">
									<cfset row ++ />
									<cfset structInsert(passArgs, "EXID", rs_task.task_exrstid, true) />
									<tr class="editRows">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><cfoutput>#rs_task.institute_short#</cfoutput></td>
										<td><cfoutput>#rs_task.course_name#</cfoutput></td>
										<td><cfoutput>#rs_task.campus_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_task.wid#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_task.examer_sum#</cfoutput></span></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					</div>
				</cfif>
				
				<cfif rs_taskPublish.recordCount>
					<div id="Published" class="tabContent">
						
						<div class="noticeBlock">
							<div class="operation">
								<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('examResitDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载课程补考时间、地点安排</span></a>
								<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('examResitStudentAllDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载补考学生名单</span></a>
							</div>
							<h3>已发布考试任务</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<cfoutput>#rs_taskPublish.recordCount#</cfoutput>场次考试已完成安排, 并向学院发布.</p>
						</div>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="25"></td>
									<td width="50">任课单位</td>
									<td>课程</td>
									<td width="50">考试校区</td>
									<td width="30">周次</td>
									<td width="80">时间</td>
									<td width="40">人数</td>
									<td width="40">考场</td>
									<td width="25"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_taskPublish">
									<cfset row ++ />
									<cfset structInsert(passArgs, "EXID", rs_taskPublish.task_exrstid, true) />
									<tr class="editRows">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><cfoutput>#rs_taskPublish.institute_short#</cfoutput></td>
										<td><cfoutput>#rs_taskPublish.course_name#</cfoutput></td>
										<td><cfoutput>#rs_taskPublish.campus_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_taskPublish.wid#</cfoutput></span></td>
										<td><cfoutput>#mathAdvice.convertWeekDayToChinese(rs_taskPublish.wdidx)#</cfoutput><cfoutput>#mathAdvice.convertExamIdxToChinese(rs_taskPublish.cellidx)#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_taskPublish.examer_sum#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_taskPublish.countCrId#</cfoutput></span></td>
										<td><a title="查看课程考试详细安排" class="stat details" href="<cfoutput>#buildURL('examResitTaskPrint', passArgs)#</cfoutput>"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</div>
				</cfif>
			
			</div>
		</li>
	</ul>
</div>




